<template>
  <div>
    <nav-bar title="我的动态"></nav-bar>
    <talk-card
        style="margin-top: 3px"
        v-for="(item,index) in activities"
        :name="item.user.userName"
        :avatar="item.user.userHead"
        :time-ago="item.updateTime"
        :num="item.loveNumber"
        :text="item.content"
        :id="item.id"
        :activity-name="item.activityName"
        :picture="item.picture"
        :like="item.love"
    ></talk-card>
  </div>
</template>

<script>
import NavBar from "@/components/NavBar/NavBar";
import talkCard from '@/components/TalkCard/index';

export default {
  name: "Mine",
  components: {
    NavBar,
    talkCard
  },
  data() {
    return {
      activities: [],
      uid: 0
    }
  },
  created() {
    this.uid = JSON.parse(localStorage.getItem('loginInfo')).id;
    this.getMineActivities();
  },
  activated() {
    this.getMineActivities();
  },
  methods: {
    getMineActivities() {
      axios.get('/activity/getByCircle', {
        params: {circleId: this.uid},
        headers: {isShowFullLoading: 'F'}
      }).then(res => {
        this.activities = [];
        this.activities.push(...res.result.result);
        //数据整理
        this.activities = this.activities.map((item) => {
          if (item.user.ybUserHead !== null || item.user.userHead == '' || item.user.userHead == null) {
            item.user.userHead = item.user.ybUserHead;
          }
          item.updateTime = _g.timeAgo(item.updateTime);
          item.picture = [];
          if (item.picture1) {
            item.picture.push(item.picture1);
          }
          if (item.picture2) {
            item.picture.push(item.picture2);
          }
          if (item.picture3) {
            item.picture.push(item.picture3);
          }
          return item;
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
